package com.tivyso.testing.mock.generator.componentfilter;

import org.apache.commons.lang.Validate;
import org.springframework.core.type.ClassMetadata;
import org.springframework.core.type.filter.AbstractClassTestingTypeFilter;

/**
 * Bridge from generator`s component filter to spring`s TypeFilter
 */
public class ComponentFilterBridge extends  AbstractClassTestingTypeFilter{

	protected final IComponentFilter componentFilter;
	
	/**
	 * @param componentFilter - filter to be bridged
	 */
	public ComponentFilterBridge(IComponentFilter componentFilter) {
		super();
		Validate.notNull(componentFilter);
		this.componentFilter = componentFilter;
	}

	@Override
	protected boolean match(ClassMetadata metadata) {
		return componentFilter.match(metadata.getClassName());
	}

}
